import React from 'react';
import {Button, ButtonProps} from "antd";
import { DeploymentUnitOutlined } from '@ant-design/icons';

import { withModal, mountModal } from "vendor/components/pro-hoc/withModal";
import DataAuth from './DataAuth';

interface DataAuthBtnProps extends ButtonProps{
    roleId: number;
    roleName: string;
    fetchList: () => void;
}

const DataAuthBtn:React.FC<DataAuthBtnProps> = ({roleId,roleName, fetchList, ...restProps}) => {

    return (
        <Button
            size="small"
            type="primary"
            icon={<DeploymentUnitOutlined />}
            onClick={() => {
                const DataAuthModal = withModal(DataAuth);
                mountModal(<DataAuthModal modalProps={{title: `${roleName}-数据授权`}} roleId={roleId} fetchList={fetchList} />)
            }}
            {...restProps}
        >数据授权</Button>
    )
};

export default DataAuthBtn;